/**
 *  跨域
 */
module.exports = () => {
  return (ctx, next) => {
    ctx.set("Access-Control-Allow-Origin", "*");
    ctx.set("Access-Control-Allow-Headers", "X-Requested-With,Content-Type");
    ctx.set("Access-Control-Allow-Methods", "PUT,POST,GET,DELETE,OPTIONS");
    if (ctx.method === "OPTIONS") {
      return (ctx.body = "");
    }
    return next();
  };
};
